<include file="__THEME__/header" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js"></script>
<script>
$CONFIG['location'] = 'msglist';
</script>
<div class="content_holder">
<div class="content no_bg">
  <!--wrap_index_r-->
  <div class="wrap_index_r">
  <include file="__THEME__/apps" />
      <div class="Box_content">
          {:Addons::hook('home_index_right_top')}
          {:W('RelatedUser',array('async'=>1))}
        <div class="right_box lineS_btm">
          <h2><a href="javascript:void(0)" onclick="$('.quick_win').show()" class="right" style="font-weight:400;font-size:12px">添加</a>关注的话题</h2>
          <dl style="display:none;" class="quick_win">
          	<dt></dt>
            <dd>
            <a href="javascript:void(0)" onclick="$('.quick_win').hide()" class="del" title="关闭"></a>
            <p>
              <input type="text" class="text" name="quick_name" style=" width:130px;display:block;margin:0 0 5px 0"/>
              <input type="button" onclick="addFollowTopic()" value="保存" class="btn_b" />
            </p>
            <p class="cGray2">请添加想关注的话题</p>
            </dd>
          </dl>
          <ul class="topic_list" rel="followTopicArea">
            <volist id="vo" name="followTopic">
              <li onmouseover="$(this).find('.del').show()" onmouseout="$(this).find('.del').hide()"><a class="del right" style="display:none" title="删除" href="javascript:void(0)" onclick="deleteFollowTopic(this,'{$vo.topic_id}')"></a><a href="{:U('home/user/topics',array('k'=>urlencode($vo['name'])))}" title="{$vo.name}">{$vo.name}</a></li>
            </volist>
          </ul>
        </div>
        <div class="right_box">
          {:W('HotTopic', array('type'=>'recommend','limit'=>5))}
          {:W('HotTopic', array('type'=>'auto','limit'=>5))}
          
          
      </div>
          {:Addons::hook('home_index_right_bottom')}
        <php>if (Addons::requireHooks('home_index_right_advert')) {</php>
        	{:Addons::hook('home_index_right_advert', array($ts['ad']['right']))}
        <php>} else {</php>
			<volist name="ts['ad']['right']" id="vo">
			<div class="ad_right"><div class="ke-post">{$vo.content}</div></div>
			</volist>
		<php>}</php>
      </div>
  </div>
  <!--wrap_index_r end-->
  <div class="wrap_index_l">
    <div class="tab-menu">
      <a href="javascript:void(0)" onclick="ui.sendmessage();" class="btn_b right">发私信</a>
	  <include file="_tab" />
    </div>
    <div class=""> 
      <ul class="feed_list">
          <li class="t">
              <span class="right pr10">共 <span id="message_list_count">{$count}</span> 封私信</span>
              <span class="left" style="padding:0px 5px 0 6px;"><input name="" type="checkbox" value="0" onclick="checkAll(this);" id="checkbox_checkAll"/></span>
              <a href="javascript:void(0)" onclick="checkAll();">全选</a>
              <i class="vline">|</i> 
              <a href="javascript:void(0)" onclick="setIsRead();">标记已读</a>
              <i class="vline">|</i> 
              <a href="javascript:void(0)" onclick="ui.confirm(this,'确定要删除该私信?')" callback="delMessage()" onclick="delMessage();">删除</a>
          </li>

          <php>if(empty($data)) {</php>暂无信息<php>}</php>

          <volist name="data" id="vo">
            <li class="lineD_btm" id="message_{$vo['list_id']}">
       	      <div class="left" style="padding:16px 5px 0 6px;"><input type="checkbox" value="{$vo.list_id}" onclick="checkon(this);"/></div>
              <div class="userPic"><space uid="vo.last_message.from_uid" target="_blank">{uavatar}</space></div>
              <div class="feed_c" style="margin-left:90px">
               	  <a href="javascript:void(0);" onclick="ui.confirm(this,'确定要删除该私信?')" callback="delMessage({$vo['list_id']})" class="hover del"></a>
                  <div class="msgCnt">
                    <switch name="vo.type">
                      <case value="1">
                        <div style="padding:0 0 10px 0" class="message_two">
                          <if condition="$vo['last_message']['from_uid'] eq $mid ">
                            <space uid="vo['last_message']['from_uid']" target="_blank">您</space> 对
                            <space uid="vo['last_message']['to_uid'][0]" target="_blank">{uname}</space> 说：
                            <else />
                            <space uid="vo['last_message']['from_uid']" target="_blank">{uname}</space> 对
                            <space uid="vo['last_message']['to_uid'][0]" target="_blank">您</space> 说：
                          </if>{$vo.last_message.content|getShort=###, 100}<if condition="$vo['new']"><span class="message_new">&nbsp;</span></if>
                        </div>
                      </case>
                      <case value="2">
                   	    <div style="padding:0 0 10px 0" class="message_group">
                          <a href="{:U('home/Message/detail', array('id'=>$vo['list_id'],'type'=>$vo['type']))}">{$vo.title}<if condition="$vo['new']"><span class="message_new">&nbsp;</span></if></a>
                        </div>
                        <div><space uid="vo.last_message.from_uid" target="_blank">{uname}</space>：{$vo.last_message.content|getShort=###, 100}</div>
                      </case>
                    </switch>
                  </div>
       		      <div>
                    <span class="right pr10">
                        
        		        <a href="{:U('home/Message/detail', array('id'=>$vo['list_id'],'type'=>$vo['type']))}">共{$vo['message_num']}条对话</a> | 
        		        <a href="{:U('home/Message/detail', array('id'=>$vo['list_id'],'type'=>$vo['type']))}">回复</a> 
                    </span>
                    <span style="color:#999">{$vo.list_ctime|friendlyDate}</span>
                  </div>
              </div>
            </li>
          </volist>

          <li class="t">
              <span class="left" style="padding:0px 5px 0 6px;"><input name="" type="checkbox" value="0" onclick="checkAll(this);" id="checkbox_checkAll"/></span>
              <a href="javascript:void(0)" onclick="checkAll();">全选</a> | 
              <a href="javascript:void(0)" onclick="setIsRead();">标记已读</a> |
              <a href="javascript:void(0)" onclick="ui.confirm(this,'确定要删除该私信?')" callback="delMessage()" onclick="delMessage();">删除</a>
          </li>
        </li>
      </ul>
      <p class="page">{$html}</p>
    </div>
    <div class="c"></div>
  </div>
  <div class="clear"></div>
</div>
</div>
<!-- 内容 end --> 

<script type="text/javascript">	
	function checkon(o){
		if( o.checked == true ){
			$(o).parents('li').addClass('bg_on') ;
		}else{
			$(o).parents('li').removeClass('bg_on') ;
		}
	}
	
	function checkAll(o){
		if( !o || o.checked == true ) {
			$('input[type="checkbox"]').attr('checked','true');
			$('ul[overstyle="on"]').addClass("bg_on");
		}else if ( o.checked == false ) {
			$('input[type="checkbox"]').removeAttr('checked');
			$('ul[overstyle="on"]').removeClass("bg_on");
		}
	}

	//获取已选择用户的ID数组
	function getChecked() {
		var ids = new Array();
		$.each($('ul input:checked'), function(i, n){
			ids.push( $(n).val() );
		});
		return ids;
	}

    function setIsRead() {
        var ids = getChecked();
        if (ids == '') ui.error('请选择私信');
        
        $.post("{:U('home/Message/doSetIsRead')}", {ids:ids.toString()}, function(res){
            if (res == '1') {
                ui.success('保存成功');
                
				for(i = 0; i < ids.length; i++) {
					$('#message_' + ids[i] + ' span.message_new').remove();
				}
            }else {
                ui.error('保存失败');
            }
        });
    }
    
    function delMessage(ids) {
        ids = ids ? ids : getChecked();
        ids = ids.toString();
        if (ids == '') return false;
        
        $.post("{:U('home/Message/doDelete')}", {ids:ids}, function(res){
            if (res == '1') {
                ui.success('删除成功');
                ids = ids.split(',');
				for(i = 0; i < ids.length; i++) {
					$('#message_'+ids[i]).remove();
				}
				var $message_list_count = $('#message_list_count');
                var message_list_count  = parseInt($message_list_count.html());
                $message_list_count.html(message_list_count - ids.length);
            }else {
                ui.error('删除失败');
            }
        });
    }
</script>
<include file="__THEME__/footer" /> 